/* 
Scenic Graphics Library
Copyright (C) 2007 Jouni Tulkki

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USApackage scenic;
*/

#include "common.h"
#include "PlainPolygonRenderer.h"


using namespace Scenic::Renderer;


PlainPolygonRenderer::PlainPolygonRenderer(Context *context)
{
	this->context = context;
	vs = new VertexStore(VSF_TEX0, context, 0);
}

PlainPolygonRenderer::~PlainPolygonRenderer()
{
	delete vs;
}

void PlainPolygonRenderer::begin()
{
	context->setPrimitives(0);
	context->device->setBlendFunc(BLEND_ONE, BLEND_ONE_MINUS_SRC_ALPHA);
}

void PlainPolygonRenderer::end()
{
	vs->endBlock();
	vs->draw();
}

void PlainPolygonRenderer::addPoint(double x, double y)
{
	vs->addVertex(x, y, context->color.getRGBA32());
}

void PlainPolygonRenderer::addTriangle(int vertex1, bool edge1, int vertex2, bool edge2, int vertex3, bool edge3)
{
	vs->addTriangle(vertex1, vertex2, vertex3);
}

